package com.ncut.user.mapper;

import com.github.pagehelper.Page;
import com.ncut.annotation.AutoFill;
import com.ncut.dto.EmployeePageQueryDTO;
import com.ncut.entity.Employee;
import com.ncut.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 插入员工数据
     *
     * @param employee
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Employee employee);

    /**
     * 分页查询
     *
     * @param employeePageQuery
     * @return
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQuery);

    /**
     * 根据id修改员工信息
     *
     * @param employee
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Employee employee);

    /**
     * 根据id查询员工信息
     *
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id};")
    Employee getById(Long id);

    /**
     * 根据id删除员工
     *
     * @param id
     */
    @Delete("delete from employee where id = #{id}")
    void deleteById(Long id);
}
